﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Animation;

namespace PushEmail
{
    public class AnimationHelper
    {
        public static void AddNewAnimation(Storyboard sb, DependencyObject source, string property, double from, double to, double transitionSpeed, IEasingFunction easingFunction = null)
        {
            DoubleAnimation animation = new DoubleAnimation();
            animation.From = from;
            animation.To = to;
            animation.Duration = TimeSpan.FromSeconds(transitionSpeed);
            if (easingFunction != null)
                animation.EasingFunction = easingFunction;
            
            Storyboard.SetTarget(animation, source);
            Storyboard.SetTargetProperty(animation, new PropertyPath(property));
            sb.Children.Add(animation);
        }
    }
}
